package vld

import (
	sqlc "bp/db/sqlc"
	"bp/internal/util"
)

// IsOfferType check string is em_offer_type
func IsOfferType(v string) (success bool) {
	switch sqlc.EmOfferType(v) {
	case sqlc.EmOfferTypeDiscount, sqlc.EmOfferTypeLimit, sqlc.EmOfferTypeCut, sqlc.EmOfferTypeQuotaCut:
		success = true
	}
	return
}

// IsOfferTypeArray check []string is []em_offer_type
func IsOfferTypeArray(v []string, emptyIsValid bool) (success bool) {
	if emptyIsValid && len(v) == 0 {
		success = true
		return
	}
	success = util.AllString(v, func(s string) bool {
		return IsOfferType(s)
	})
	return
}
